home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / atre27.exe / ATREE_27 / OCRDEMO2 / BITMAP.H < prev    next >
C/C++ Source or Header  |  1992-08-01  |  7KB  |  161 lines

  1. /*****************************************************************************
  2.  ****                                                                     ****
  3.  **** bitmap.h                                                            ****
  4.  ****                                                                     ****
  5.  **** atree release 2.7 for Windows                                       ****
  6.  **** Adaptive Logic Network (ALN) simulation program.                    ****
  7.  **** Copyright (C) M. Thomas, N. Sanche, W.W. Armstrong 1991, 1992       ****
  8.  ****                                                                                       ****
  9.  **** License:                                                            ****
  10.  **** A royalty-free license is granted for the use of this software for  ****
  11.  **** NON_COMMERCIAL PURPOSES ONLY. The software may be copied and/or     ****
  12.  **** modified provided this notice appears in its entirety and unchanged ****
  13.  **** in all derived source programs.  Persons modifying the code are     ****
  14.  **** requested to state the date, the changes made and who made them     ****
  15.  **** in the modification history.                                        ****
  16.  ****                                                                     ****
  17.  **** Patent License:                                                     ****
  18.  **** The use of a digital circuit which transmits a signal indicating    ****
  19.  **** heuristic responsibility is protected by U. S. Patent 3,934,231     ****
  20.  **** and others assigned to Dendronic Decisions Limited of Edmonton,     ****
  21.  **** W. W. Armstrong, President.  A royalty-free license is granted      ****
  22.  **** by the company to use this patent for NON_COMMERCIAL PURPOSES to    ****
  23.  **** adapt logic trees using this program and its modifications.         ****
  24.  ****                                                                     ****
  25.  **** Limited Warranty:                                                   ****
  26.  **** This software is provided "as is" without warranty of any kind,     ****
  27.  **** either expressed or implied, including, but not limited to, the     ****
  28.  **** implied warrantees of merchantability and fitness for a particular  ****
  29.  **** purpose.  The entire risk as to the quality and performance of the  ****
  30.  **** program is with the user.  Neither the authors, nor the             ****
  31.  **** University of Alberta, its officers, agents, servants or employees  ****
  32.  **** shall be liable or responsible in any way for any damage to         ****
  33.  **** property or direct personal or consequential injury of any nature   ****
  34.  **** whatsoever that may be suffered or sustained by any licensee, user  ****
  35.  **** or any other party as a consequence of the use or disposition of    ****
  36.  **** this software.                                                      ****
  37.  **** Modification history:                                               ****
  38.  ****                                                                     ****
  39.  **** 92.04.27 atree v2.5 for Windows, M. Thomas                          ****
  40.  **** 92.03.07 Release 2.6, Monroe Thomas, Neal Sanche                    ****
  41.  **** 92.01.08 Release 2.7, Monroe Thomas, Neal Sanche                    ****
  42.  ****                                                                     ****
  43.  *****************************************************************************/
  44.  
  45. // bitmap.h header for bitmap and bitmap control objects
  46.  
  47. #include <owl.h>
  48. #include <math.h>
  49. #include <alloc.h>
  50. #include <control.h>
  51.  
  52. _CLASSDEF(TBitmap)
  53. class TBitmap
  54. {
  55. protected:
  56.  
  57.     HBITMAP hBitmap;
  58.     COLORREF crDraw;
  59.     COLORREF crErase;
  60.  
  61. public:
  62.  
  63.     virtual void Init(HBITMAP hABitmap);
  64.  
  65.     TBitmap(HBITMAP hABitmap)
  66.         {   hBitmap = NULL; Init(hABitmap); }
  67.  
  68.     ~TBitmap() { if (hBitmap != NULL) DeleteObject(hBitmap); }
  69.  
  70.     HBITMAP GetBitmap() { return(hBitmap); }
  71.     DWORD GetBits(LPSTR lpBits);
  72.     LONG SetBits(LPSTR lpBits, DWORD dwCount);
  73.     DWORD GetWidth();
  74.     DWORD GetHeight();
  75.     DWORD GetPlanes();
  76.     DWORD GetBitsPixel();
  77.     DWORD GetWidthBytes();
  78.     DWORD GetBytes();
  79.     COLORREF GetDrawColor();
  80.     COLORREF SetDrawColor(COLORREF crColor);
  81.     COLORREF GetEraseColor();
  82.     COLORREF SetEraseColor(COLORREF crColor);
  83.     virtual DWORD GetPoint(int x, int y);
  84.     virtual DWORD SetPoint(int x, int y, COLORREF crColor);
  85.     virtual void Rotate(float theta, BOOL isRadians = FALSE);
  86. };
  87.  
  88. _CLASSDEF(TBitmapControl)
  89. class TBitmapControl : public TControl, public TBitmap
  90. {
  91. public:
  92.  
  93.     virtual void Init(HBITMAP hABitmap)
  94.         { TBitmap::Init(hABitmap); }
  95.  
  96.     TBitmapControl(PTWindowsObject AParent, int AnId, LPSTR ATitle, int X,
  97.                      int Y, int W, int H, HBITMAP hABitmap,
  98.                      PTModule AModule = NULL) : TControl(AParent, AnId,
  99.                         ATitle, X, Y, W, H, AModule), TBitmap(hABitmap)
  100.             { Init(hABitmap); }
  101.  
  102.     TBitmapControl(PTWindowsObject AParent, int ResId, HBITMAP hABitmap,
  103.                      PTModule AModule = NULL) : TControl(AParent, ResId, AModule),
  104.                      TBitmap(hABitmap)
  105.             { DisableAutoCreate(); Init(hABitmap); }
  106.  
  107.     virtual LPSTR GetClassName() { return ("TBitmapControl"); }
  108.     virtual void GetWindowClass(WNDCLASS &);
  109.     virtual void Paint(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);
  110.     virtual void Refresh()
  111.         { InvalidateRect(HWindow, NULL, FALSE); UpdateWindow(HWindow); }
  112.     virtual DWORD GetPoint(int x, int y);
  113.     virtual DWORD SetPoint(int x, int y, COLORREF crColor);
  114.     virtual void Reset(short w, short h);
  115. };
  116.  
  117. _CLASSDEF(TBitmapDrawControl)
  118. class TBitmapDrawControl : public TBitmapControl
  119. {
  120. protected:
  121.  
  122.     BOOL TBDCClear;
  123.     BOOL TBDCRotate;
  124.     BOOL drawon;
  125.     BOOL eraseon;
  126.  
  127.     void setdimensions(HDC wndDC);
  128.  
  129. public:
  130.  
  131.     virtual void Init(HBITMAP hABitmap)
  132.     {
  133.         TBitmapControl::Init(hABitmap);
  134.         crDraw = RGB(0, 0, 0);
  135.         crErase = RGB(255, 255, 255);
  136.         drawon = eraseon = FALSE;
  137.     }
  138.  
  139.     TBitmapDrawControl(PTWindowsObject AParent, int AnId, LPSTR ATitle, int X,
  140.                      int Y, int W, int H, HBITMAP hABitmap,
  141.                      PTModule AModule = NULL) : TBitmapControl(AParent, AnId,
  142.                         ATitle, X, Y, W, H, hABitmap, AModule)
  143.         { Init(hABitmap); }
  144.  
  145.     TBitmapDrawControl(PTWindowsObject AParent, int ResId, HBITMAP hABitmap,
  146.                      PTModule AModule = NULL) : TBitmapControl(AParent, ResId, hABitmap, AModule)
  147.         { Init(hABitmap); }
  148.  
  149.     virtual LPSTR GetClassName() { return ("TBitmapDrawControl"); }
  150.     virtual void GetWindowClass(WNDCLASS &);
  151.     virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN];
  152.     virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP];
  153.     virtual void WMLButtonDblClk(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDBLCLK];
  154.     virtual void WMRButtonDown(RTMessage Msg) = [WM_FIRST + WM_RBUTTONDOWN];
  155.     virtual void WMRButtonUp(RTMessage Msg) = [WM_FIRST + WM_RBUTTONUP];
  156.     virtual void WMRButtonDblClk(RTMessage Msg) = [WM_FIRST + WM_RBUTTONDBLCLK];
  157.     virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE];
  158. };
  159.  
  160. #define TBDC_COORDCHANGE WM_USER + 99
  161.